package com.ylstm.service.impl;

import com.ylstm.mapper.UserMapper;
import com.ylstm.pojo.User;
import com.ylstm.service.UserService;
import com.ylstm.utils.ResultMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @ClassName UserServiceImpl
 * @Description TODO
 * @date 2022/7/31 15:19
 * @Version 1.0
 */
    @Service
    public class UserServiceImpl implements UserService {
        @Autowired
        private UserMapper userMapper;
    /*用户登录*/
    @Override
    public ResultMessage userLogin(String username, String password) {
        User user = userMapper.userLogin(username, password);
        ResultMessage resultMessage = new ResultMessage();
        if (user  != null){
            resultMessage.setCode(222);
        }else {
            resultMessage.setCode(233);
        }
        return  resultMessage;
    }
    /*检注册查用户名是否重复*/
    @Override
    public ResultMessage checkUsername(String username) {
        User user = userMapper.checkUser(username);
        ResultMessage resultMessage = new ResultMessage() ;
        if (user == null){
            //如果没有找到用户表示可以注册
            resultMessage.setCode(222);
        }else{
            resultMessage.setCode(233);
        }
         return resultMessage;
    }
}
